/*
 定义Action
 API 调用 产生如下的3个函数
 Object {
 request : request(login)
 success : success(login, response)
 failure : failure(login, error)
 }
 调用方式
 userLogin.request()(login)
 */

import {createAction} from 'redux-actions';
import * as Types from './ActionTypes'

// 用户登录Action
export const userLogin = {
  request: (login) => createAction(Types.USER_LOGIN.REQUEST, {login}),
  success: (response) => createAction(Types.USER_LOGIN.SUCCESS, {response}),
  failure: (error) => createAction(Types.USER_LOGIN.FAILURE, {error}),
}

// 用户退出Action
export const userLogout = {
  request: () => createAction(Types.USER_LOGOUT.REQUEST, {}),
  success: (response) => createAction(Types.USER_LOGOUT.SUCCESS, {response}),
  failure: (error) => createAction(Types.USER_LOGOUT.FAILURE, {error}),
}

// 用户获取菜单Action
export const userMenu = {
  request: () => createAction(Types.USER_MENU.REQUEST, {}),
  success: (response) => createAction(Types.USER_MENU.SUCCESS, {response}),
  failure: (error) => createAction(Types.USER_MENU.FAILURE, {error}),
}

// 学生个人信息Action
export const studentProfile = {
  request: () => createAction(Types.STUDENT_PROFILE.REQUEST, {}),
  success: (response) => createAction(Types.STUDENT_PROFILE.SUCCESS, {response}),
  failure: (error) => createAction(Types.STUDENT_PROFILE.FAILURE, {error}),
}

// 公司信息查询Action
export const companyQuery = {
  request: () => createAction(Types.COMPANY_QUERY.REQUEST, {}),
  success: (response) => createAction(Types.COMPANY_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.COMPANY_QUERY.FAILURE, {error}),
}

export const profileUpdate = (profile) => createAction(Types.PROFILE_UPDATE, {profile})

export const companyUpdate = (company) => createAction(Types.COMPANY_UPDATE, {company})

export const orderApplyFinish = () => createAction(Types.ORDER_APPLY_FINISH, {})

export const checkToken = {
  request: () => createAction(Types.CHECK_TOKEN.REQUEST, {}),
  success: (response) => createAction(Types.CHECK_TOKEN.SUCCESS, {response}),
  failure: (error) => createAction(Types.CHECK_TOKEN.FAILURE, {error}),
}

// 提交签约申请Action
export const orderApply = {
  request: (order) => createAction(Types.ORDER_APPLY.REQUEST, {order}),
  success: (response) => createAction(Types.ORDER_APPLY.SUCCESS, {response}),
  failure: (error) => createAction(Types.ORDER_APPLY.FAILURE, {error}),
}

// 提交待审批签约信息查询列表Action
export const ordersQuery = {
  request: () => createAction(Types.ORDERS_QUERY.REQUEST, {}),
  success: (response) => createAction(Types.ORDERS_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.ORDERS_QUERY.FAILURE, {error}),
}

// 提交待审批签约信息查询单个Action
export const orderQuery = {
  request: (id) => createAction(Types.ORDER_QUERY.REQUEST, {id}),
  success: (response) => createAction(Types.ORDER_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.ORDER_QUERY.FAILURE, {error}),
}

// 发起审批历史查询Action
export const timeLineQuery = {
  request: (studentId) => createAction(Types.TIMELINE_QUERY.REQUEST, {studentId}),
  success: (response) => createAction(Types.TIMELINE_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.TIMELINE_QUERY.FAILURE, {error}),
}

// 发起审批历史查询Action
export const orderCheck = {
  request: (order) => createAction(Types.ORDER_CHECK.REQUEST, {order}),
  success: (response) => createAction(Types.ORDER_CHECK.SUCCESS, {response}),
  failure: (error) => createAction(Types.ORDER_CHECK.FAILURE, {error}),
}

// 发起上传文件状态查询Action
export const uploadListQuery = {
  request: (param) => createAction(Types.UPLOAD_LIST_QUERY.REQUEST, {param}),
  success: (response) => createAction(Types.UPLOAD_LIST_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.UPLOAD_LIST_QUERY.FAILURE, {error}),
}

// 导入详细信息查询
export const uploadDetailQuery = {
  request: (id) => createAction(Types.UPLOAD_DETAIL_QUERY.REQUEST, {id}),
  success: (response) => createAction(Types.UPLOAD_DETAIL_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.UPLOAD_DETAIL_QUERY.FAILURE, {error}),
}

// 学生数据批量查询
export const studentsQuery = {
  request: (param) => createAction(Types.STUDENTS_QUERY.REQUEST, {param}),
  success: (response) => createAction(Types.STUDENTS_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.STUDENTS_QUERY.FAILURE, {error}),
}

// 学生数据批量删除
export const studentsDelete = {
  request: (param) => createAction(Types.STUDENTS_DELETE.REQUEST, {param}),
  success: (response) => createAction(Types.STUDENTS_DELETE.SUCCESS, {response}),
  failure: (error) => createAction(Types.STUDENTS_DELETE.FAILURE, {error}),
}

// 用人单位数据查询
export const companysQuery = {
  request: (param) => createAction(Types.COMPANYS_QUERY.REQUEST, {param}),
  success: (response) => createAction(Types.COMPANYS_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.COMPANYS_QUERY.FAILURE, {error}),
}

// 用人单位数据删除
export const companysDelete = {
  request: (param) => createAction(Types.COMPANYS_DELETE.REQUEST, {param}),
  success: (response) => createAction(Types.COMPANYS_DELETE.SUCCESS, {response}),
  failure: (error) => createAction(Types.COMPANYS_DELETE.FAILURE, {error}),
}

// 发送通知用人单位
export const companyNotify = {
  request: (param) => createAction(Types.COMPANY_NOTIFY.REQUEST, {param}),
  success: (response) => createAction(Types.COMPANY_NOTIFY.SUCCESS, {response}),
  failure: (error) => createAction(Types.COMPANY_NOTIFY.FAILURE, {error}),
}

// 用人单位录入
export const enterpiseCreate = {
  request: (param) => createAction(Types.ENTERPRISE_CREATE.REQUEST, {param}),
  success: (response) => createAction(Types.ENTERPRISE_CREATE.SUCCESS, {response}),
  failure: (error) => createAction(Types.ENTERPRISE_CREATE.FAILURE, {error}),
}

export const studentsDeleteNotify = (ids) => createAction(Types.STUDENTS_DELETE_NOTIFY, {ids})

export const companyNotifyClear = () => createAction(Types.COMPANY_NOTIFY_CLEAR, {})

export const enterpriseCreateClear = () => createAction(Types.ENTERPRISE_CREATE_CLEAR, {})

export const companysDeleteNotify = (ids) => createAction(Types.COMPANYS_DELETE_NOTIFY, {ids})

export const checkOneUnmount = () => createAction(Types.CHECK_ONE_UNMOUNT, {})

//查询有无未读的通知
export const notificationUnreadQuery = {
  request: () => createAction(Types.NOTIFICATION_UNREAD_QUERY.REQUEST, {}),
  success: (response) => createAction(Types.NOTIFICATION_UNREAD_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.NOTIFICATION_UNREAD_QUERY.FAILURE, {error}),
};

//查询有无未读的通知
export const notificationNewQuery = {
  request: () => createAction(Types.NOTIFICATION_NEW_QUERY.REQUEST, {}),
  success: (response) => createAction(Types.NOTIFICATION_NEW_QUERY.SUCCESS, {response}),
  failure: (error) => createAction(Types.NOTIFICATION_NEW_QUERY.FAILURE, {error}),
};
//将通知标记为已读
export const notificationMarkReaded = {
  request: (ids) => createAction(Types.NOTIFICATION_MARK_READED.REQUEST, {ids}),
  success: (response) => createAction(Types.NOTIFICATION_MARK_READED.SUCCESS, {response}),
  failure: (error) => createAction(Types.NOTIFICATION_MARK_READED.FAILURE, {error}),
};








